package com.mall.api.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mall.bean.dto.ProductDto;
import com.mall.common.responses.ServerResponseEntity;
import com.mall.common.utils.PageParam;
import com.mall.service.ProductService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("prod")
public class ProductController {
    @Autowired
    private ProductService productService;

    //首页页面   仅仅获取简单的几件商品
    //分页获取热门商品
    @GetMapping("/prodListByTagId")
    @Operation(summary = "通过分组标签获取商品列表" , description = "通过分组标签id（tagId）获取商品列表")
    @Parameters({
            @Parameter(name = "tagId", description = "当前页，默认为1" , required = true),
    })
    public ServerResponseEntity<IPage<ProductDto>> getInfo(
            @RequestParam(value = "tagId") long tagId, PageParam<ProductDto> page){
        IPage<ProductDto> productPage = productService.pageByTagId(page, tagId);
        return ServerResponseEntity.success(productPage);
    }

    //获取分类后的商品
    @RequestMapping("getProdPage")
    @Operation(summary = "获取分类的商品",description = "根据分类的id查询分类的商品")
    public void getProdPage(@RequestParam(value = "categoryId") Long categoryId,PageParam<ProductDto> page){


    }


    //每日上新
    @GetMapping("/getNewProd")
    @Operation(summary = "新品推荐的商品列表",description = "根据商品上架时间获取")
    public void getNewProd(@RequestParam PageParam<ProductDto> page){


    }

    //商城热卖
    @RequestMapping("/hotProdList")
    @Operation(summary = "商品热卖列表",description = "火热商品，根据销量数决定")
    public void getHotProd(PageParam<ProductDto> page){

    }


    //更多宝贝



    //商品详情
    @GetMapping("/prodInfo")
    @Operation(summary = "商品详情",description = "商品id查询")
    @Parameter(name = "prodId", description = "商品ID" , required = true)
    public void getProdDetails(Long id){

    }

    //领优惠券




}
